<?php
	// error_reporting(E_ALL|E_STRICT);
	// error_reporting(1);
	// @ini_set('display_errors','1');
	date_default_timezone_set('Asia/Saigon');
	// Dinh nghia duong dan den thu vien cua Zend
	set_include_path('./library/'
			. PATH_SEPARATOR . './application/models'. PATH_SEPARATOR . './application/');
	
	// Goi class Zend_Load
	include "./library/Zend/Loader.php";	
	/*include "./library/Efy/pclzip.lib.php";	*/
	//Goi class Controller
	Zend_Loader::loadClass('Zend_Controller_Front');	
	Zend_Loader::loadClass('Zend_View');	
	Zend_Loader::loadClass('Zend_Config_Ini');		
	Zend_Loader::loadClass('Zend_Config_Xml');		
	Zend_Loader::loadClass('Zend_Registry');
	Zend_Loader::loadClass('Zend_Layout');	
	Zend_Loader::loadClass('Zend_Db');	
	Zend_Loader::loadClass('Efy_Db_Connection');	
	Zend_Loader::loadClass('Efy_Library');		
	Zend_Loader::loadClass('Efy_Xml');
	Zend_Loader::loadClass('Efy_Init_Session');	
	Zend_Loader::loadClass('Efy_Init_Config');	
	Zend_Loader::loadClass('Efy_Init_Const');	
	Zend_Loader::loadClass('Efy_Function_RecordFunctions'); //Goi lop tao cac phuong thuc dung chung
	/*Zend_Loader::loadClass('Efy_Publib_Browser'); */
	/*Zend_Loader::loadClass('Efy_phpDocx');*/
	//@session_start();
	Zend_Session::start();
	//Khai bao bien toan cuc 
	$conDirApp = new Zend_Config_Ini('./config/config.ini','dirApp');
	$registry = Zend_Registry::getInstance();
	$registry->set('conDirApp', $conDirApp);	
	
	//Dinh nghia hang so dung chung 
	$ConstPublic = new Zend_Config_Ini('./config/config.ini','ConstPublic');
	$registry = Zend_Registry::getInstance();
	$registry->set('ConstPublic', $ConstPublic);	
	
	//Ket noi CSDL SQL theo kieu ADODB
	$connectSQL = new Zend_Config_Ini('./config/config.ini','dbmssql');
	$registry = Zend_Registry::getInstance();
	$registry->set('connectSQL', $connectSQL);
	$connAdo = Efy_Db_Connection::connectADO($connectSQL->db->adapter,$connectSQL->db->config->toArray());
	//$Efy_Init_Config = new Efy_Init_Config();
	/*
	if('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] != $Efy_Init_Config->_setUserLoginUrl()){
		$owc = $Efy_Init_Config->_setWebSitePath();
		$owc = str_replace("/", "", $owc);				
		//Kiem tra user da dang nhap phan mem hay chua				
		if(!isset($_SESSION['staff_id']) || is_null($_SESSION['staff_id'])){				
			//Kiem tra thong tin NSD?>
			<script type="text/javascript">
				 UrlRes = '<?php echo $Efy_Init_Config->_setUserLoginUrl() ?>';					 
				 window.location = UrlRes; 					
			</script><?php	
		}
		else{
			if (!isset($_SESSION['INFORMATION_STAFF_LOGIN_MTL'])) {
				$staffName = Efy_Publib_Library::_getItemAttrById($_SESSION['arr_all_staff'],$_SESSION['staff_id'],'name');
				$positionCode = Efy_Publib_Library::_getItemAttrById($_SESSION['arr_all_staff'],$_SESSION['staff_id'],'position_code');
				$unitId = Efy_Publib_Library::_getItemAttrById($_SESSION['arr_all_staff'],$_SESSION['staff_id'],'unit_id');
				$unitName = Efy_Publib_Library::_getItemAttrById($_SESSION['arr_all_unit'],$unitId,'name');
                $baseUrl = $Efy_Init_Config->_setLibUrlPath();
				$_SESSION['INFORMATION_STAFF_LOGIN_MTL'] = efy_library::_getInformationStaffLoginMtl($staffName,$positionCode,$unitName,$baseUrl);
			}
			//Check tree
			$objefy = new Efy_Library();
			$objefy->checkdatatree();
		}
	}
	*/
	// setup controller
	$frontController = Zend_Controller_Front::getInstance();	
	$frontController->addControllerDirectory('./application/controllers');
	$frontController->addControllerDirectory('./application/listxml/controllers', 'listxml');
	$frontController->addControllerDirectory('./application/logout/controllers','logout');
	$frontController->addControllerDirectory('./application/login/controllers','login');
	$frontController->addControllerDirectory('./application/user/controllers','user');
	$frontController->addControllerDirectory('./application/mtl/controllers', 'mtl');
	$frontController->addControllerDirectory('./application/public/controllers', 'public');
	$frontController->addControllerDirectory('./application/ajax/controllers', 'ajax');
	$frontController->addControllerDirectory('./application/web/controllers', 'web');
	$frontController->throwExceptions(true);		
	$frontController->setDefaultModule('login');	
	$frontController->dispatch();
?>